<!DOCTYPE html>
<html><head>
	    <meta charset="utf-8">
    <title>ThinkPHP5.0</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__ADMIN__/style/bootstrap.css" rel="stylesheet">
    <link href="__ADMIN__/style/font-awesome.css" rel="stylesheet">
    <link href="__ADMIN__/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__ADMIN__/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__ADMIN__/style/demo.css" rel="stylesheet">
    <link href="__ADMIN__/style/typicons.css" rel="stylesheet">
    <link href="__ADMIN__/style/animate.css" rel="stylesheet">
    <script src="__ADMIN__/style/jquery_002.js"></script>
    <script src="__ADMIN__/plus/layer/layer.js"></script>
    <script src="__ADMIN__/plus/uploadify/jquery.uploadify.min.js"></script>
    <script src="__ADMIN__/plus/ueditor/ueditor.config.js"></script>
    <script src="__ADMIN__/plus/ueditor/ueditor.all.min.js"></script>
    <script src="__ADMIN__/plus/ueditor/lang/zh-cn/zh-cn.js"></script> 
    <script type="text/javascript">
    $(function () {
            $("#uploadify").uploadify({
                //指定swf文件
                'swf': "__ADMIN__/plus/uploadify/uploadify.swf",
                //后台处理的页面
                'uploader': "{:url('Content/upimg')}",
                'progressData' : 'speed',
                //按钮显示的文字
                'buttonText': '上传文件',
                //按钮样式
                'buttonClass': 'btn btn-azure',
                //显示的高度和宽度，默认 height 30；width 120
                //'height': 15,
                //'width': 80,
                //上传文件的类型  默认为所有文件    'All Files'  ;  '*.*'
                //在浏览窗口底部的文件类型下拉菜单中显示的文本
                'fileTypeDesc': 'Image Files',
                //设定发送数据的name值
                'fileObjName':'img',
                'sizeLimit': 10240,//限制大小
                //允许上传的文件后缀   
                'onUploadSuccess' : function(file,data,response){
                    $("input[name='litpic']").val(data);
                    var imgsrc="__INDEX__/uploads/img/"+data;
                    var img="<img height='100' src='"+imgsrc+"'>";
                    $("#imgdiv").show();
                    $("#litpic").html(img);

                }        
            });
            $("#uploadify-button").prepend("<i style='padding-right:4px;' class='fa fa-upload'></i>");
            $("#uploadify-button").removeAttr('style');
        });

    

    </script>   
</head>
<body>
	<!-- 头部 -->
	{include file="common/head"}
	<!-- /头部 -->
	
	<div class="main-container container-fluid">
		<div class="page-container">
			<!-- Page Sidebar -->
                {include file="common/left"}
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                                        <li>
                        <a href="#">系统</a>
                    </li>
                                        <li>
                        <a href="#">文档管理</a>
                    </li>
                                        <li class="active">添加文档</li>
                                        </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">
                    
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-header bordered-bottom bordered-blue">
                <span class="widget-caption">新增文档</span> 
            </div>
            <div class="widget-body">
                <div id="horizontal-form">
                    <form class="form-horizontal" role="form" action="" method="post" enctype="multipart/form-data" >
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">标题</label>
                            <div class="col-sm-6">
                                <input class="form-control" placeholder="" name="title" required="" type="text">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>

                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">属性</label>
                            <div class="col-sm-6">
                                <div class="checkbox" style="float:left; padding-left:10px;">
                                    <label>
                                        <input name="attr[]" class="colored-blue" value="头条" type="checkbox">
                                        <span class="text">头条</span>
                                    </label>
                                </div>

                                <div class="checkbox" style="float:left; padding-left:10px;">
                                    <label>
                                        <input name="attr[]" class="colored-blue" value="推荐" type="checkbox">
                                        <span class="text">推荐</span>
                                    </label>
                                </div>

                                <div class="checkbox" style="float:left; padding-left:10px;">
                                    <label>
                                        <input name="attr[]" class="colored-blue" value="幻灯" type="checkbox">
                                        <span class="text">幻灯</span>
                                    </label>
                                </div>

                                <div class="checkbox" style="float:left; padding-left:10px;">
                                    <label>
                                        <input name="attr[]" class="colored-blue" value="加粗" type="checkbox">
                                        <span class="text">加粗</span>
                                    </label>
                                </div>

                                <div class="checkbox" style="float:left; padding-left:10px;">
                                    <label>
                                        <input name="attr[]" class="colored-blue" value="图片" type="checkbox">
                                        <span class="text">图片</span>
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">所属栏目</label>
                            <div class="col-sm-6">
                                    {volist name="cateRes" id="cate"}
                                        {if condition="$cate['id'] eq $cateId"} 
                                        <span class="form-control">{$cate.cate_name} </span>
                                        <input type="hidden" name="cate_id" value="{$cate.id}">
                                        {/if}
                                    {/volist}
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>

                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">关键词</label>
                            <div class="col-sm-6">
                                <input class="form-control" placeholder="" name="keywords" required="" type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">描述</label>
                            <div class="col-sm-6">
                                <textarea name="description" class="form-control"></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">作者</label>
                            <div class="col-sm-6">
                                <input class="form-control" placeholder="" name="writer" required="" type="text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">来源</label>
                            <div class="col-sm-6">
                                <input class="form-control" placeholder="" name="source" required="" type="text">
                            </div>
                        </div>

                        <div class="form-group">
                                        <label for="username" class="col-sm-2 control-label no-padding-right">缩略图</label>
                                        <div class="col-sm-6">
                                            <label>
                                                <span id="uploadify"></span>
                                                <span class="text"></span>
                                                <input name="litpic" value="" type="hidden">
                                            </label>
                                            <label>
                                                <div id="cancel" style="float:left;" class="uploadify-button btn btn-azure"><span class="uploadify-button-text"><i style="padding-right:4px;" class="fa fa-rotate-left"></i>撤销上传</span></div>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="form-group" id="imgdiv" style="display:none;">
                                        <label for="username" class="col-sm-2 control-label no-padding-right"></label>
                                        <div class="col-sm-6">
                                            <label id="litpic">
                                            </label>
                                        </div>
                                        <p class="help-block col-sm-4 red">* 必填</p>
                                    </div>
                        <!-- <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">缩略图</label>
                            <div class="col-sm-6">
                                <input placeholder="" name="litpic" required="" type="file">
                            </div>
                        </div> -->
                        <!-- 自定义字段开始 -->
                        <?php foreach ($diyFields as $k => $v):?>
                            <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right"><?php echo $v['field_cname'];?></label>
                            <div class="col-sm-6">
                               <?php switch ($v['field_type']) {
                                    case 1:
                                    case 7:
                                    case 8:
                                        // $fileType='varchar(150) not null default ""';
                                        echo "<input type='text' name='".$v['field_ename']."' class='form-control'>";
                                        break;
                                    case 5:
                                         echo "<textarea class='form-control' name='".$v['field_ename']."'></textarea>";
                                        break;
                                    case 6:
                                         echo "<input type='file' name='".$v['field_ename']."' >";
                                        break;
                                    case 2:
                                        if($v['field_values']){
                                            $arr=explode(',', $v['field_values']);
                                            foreach ($arr as $k1 => $v1) {
                                                echo "<div class='radio' style='float:left; padding-left:10px;'>";
                                                echo "<label>";
                                                echo "<input type='radio' name='".$v['field_ename']."' value='".$v1."' class='colored-blue'>";
                                                echo "<span class='text'>$v1</span> ";
                                                echo "</label>  ";
                                                echo "</div>";
                                            }
                                        }
                                        
                                        break;
                                    case 3:
                                        if($v['field_values']){
                                            $arr=explode(',', $v['field_values']);
                                            foreach ($arr as $k1 => $v1) {
                                                echo "<div class='checkbox' style='float:left; padding-left:10px;'>";
                                                echo "<label>";
                                                echo "<input type='checkbox' name='".$v['field_ename']."[]' value='".$v1."' class='colored-blue'>";
                                                echo "<span class='text'>$v1</span> ";
                                                echo "</label>  ";
                                                echo "</div>";
                                            }
                                        }
                                        break;
                                    case 4:
                                        if($v['field_values']){
                                            $arr=explode(',', $v['field_values']);
                                            echo "<select name='".$v['field_ename']."'>";
                                            foreach ($arr as $k1 => $v1) {
                                                echo "<option value='".$v1."'>".$v1."</option>";
                                            }
                                            echo "</select>";
                                        }
                                        break;
                                    case 9:
                                        echo get_ueditor($v['field_ename']);
                                        break;
                                    default:
                                        echo "<input type='text' name='".$v['field_ename']."' class='form-control'>";
                                        break;
                                } ?>
                            </div>
                        </div>
                        <?php endforeach;?>
                        <!-- 自定义字段结束 -->

                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label no-padding-right">内容</label>
                            <div class="col-sm-6">
                                <textarea name="content" id="content"></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="group_id" class="col-sm-2 control-label no-padding-right">点击数</label>
                            <div class="col-sm-6">
                               <input class="form-control" placeholder="" name="click" required="" type="text">
                            </div>
                        </div>  
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default">保存信息</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
		</div>	
	</div>

	    <!--Basic Scripts-->
    <script src="__ADMIN__/style/bootstrap.js"></script>
    <!--Beyond Scripts-->
    <script src="__ADMIN__/style/beyond.js"></script>
    <script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例

    UE.getEditor('content',{toolbars:[
        [
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            // 'directionalityltr', 'directionalityrtl', 'indent', '|',
            // 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
            // 'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
            // 'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment'
        ]

        ],initialFrameWidth:1000,initialFrameHeight:400});
    
        $("#cancel").click(function(){
        var imgurl=$("input[name='litpic']").val();
        if(!imgurl){
            // alert('请先上传图片！');
            layer.msg('请先上传图片！', {icon: 2});
            return false;
        }
        // if(!confirm('确定要撤销图片吗？')){
        //     return false;
        // }
        layer.confirm('确定要撤销图片吗？', {icon: 3, title:'提示'}, function(index){
          //do something
        $("#imgdiv").hide();
        $("input[name='litpic']").val('');
        $.ajax({
            type:"post",
            dataType:"json",
            data:{imgurl:imgurl},
            url:"{:url('Content/delimg')}",
            success:function(data){
                if(data==1){
                    layer.msg('撤销成功！', {icon: 1});
                }else{
                    layer.msg('撤销失败！', {icon: 2});
                }
            }
        });
          layer.close(index);
        });
        
    });
    </script>
    

</body></html>